﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using MySql.Data;
using MySql.Data.MySqlClient;
using System.Data.SqlClient ;

/// <summary>
/// Summary description for Functions
/// </summary>
/// 
namespace PrimaryKeyFunction
{
    public class Functions
    {
        public Functions()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        public int GetPrimaryKey(string table, string IdName, int refkey)
        {
            MySqlConnection conn = new MySqlConnection((string)ConfigurationSettings.AppSettings["LitReviewConnection"]);
            MySqlCommand cmd1;

            try
            {
                conn.Open();
                cmd1 = new MySqlCommand("select " + IdName + " from " + table + " where ref_fk=" + refkey, conn);
                int UltRefKey = Convert.ToInt32(cmd1.ExecuteScalar());
                return UltRefKey;
            }

            finally
            {
                conn.Close();

            }
        }

        public string UpdateExperiment(string inproxanal_fk, string inultanal_fk, string incalanal_fk, string instruct_fk, string inphysprops_fk, string inconvcond_fk, string inliquid_fk, string inchr_fk, string inncgas_fk, string ingas_fk, string inaqueous_fk, string inoil_fk, string inwater_fk, string stringBioUA_fk, string stringGasYield_fk, string stringPyr_Cal_fk, string Pry_Char_fk, string stringPyrOil_fk, string stringMaterialFk, string vcexp_summary, string vcsource, string vchandlingHistory)
        {
            
          MySqlConnection conn = new MySqlConnection((string)ConfigurationSettings.AppSettings["LitReviewConnection"]);
          MySqlCommand cmd1;
          try
           {

            conn.Open();

            string storedProcedure = "Experiment_Update_Final";

            cmd1 = new MySqlCommand(storedProcedure, conn);

            cmd1.CommandType = CommandType.StoredProcedure;

            MySqlParameter[] para = new MySqlParameter[22];


            para[0] = new MySqlParameter();
            para[0].ParameterName = "inproxanal_fk";
            if (inproxanal_fk == string.Empty)
            {
                para[0].Value = null;
            }
            else
            {
                para[0].Value =int.Parse(inproxanal_fk);
            }

            para[1] = new MySqlParameter();
            para[1].ParameterName = "inultanal_fk";
            if (inultanal_fk == string.Empty)
            {
                para[1].Value = null;
            }
            else
            {
                para[1].Value = int.Parse(inultanal_fk);
            }

            para[2] = new MySqlParameter();
            para[2].ParameterName = "incalanal_fk";
            if (incalanal_fk == string.Empty)
            {
                para[2].Value = null;
            }
            else
            {
                para[2].Value =int.Parse(incalanal_fk);
            }

            para[3] = new MySqlParameter();
            para[3].ParameterName = "instruct_fk";
            if (instruct_fk == string.Empty)
            {
                para[3].Value = null;
            }
            else
            {
                para[3].Value =int.Parse(instruct_fk);
            }

            para[4] = new MySqlParameter();
            para[4].ParameterName = "inphysprops_fk";
            if (inphysprops_fk == string.Empty)
            {
                para[4].Value = null;
            }
            else
            {
                para[4].Value = int.Parse(inphysprops_fk);
            }

            para[5] = new MySqlParameter();
            para[5].ParameterName = "inconvcond_fk";
            if (inconvcond_fk == string.Empty)
            {
                para[5].Value = null;
            }
            else
            {
                para[5].Value = int.Parse(inconvcond_fk);
            }

            para[6] = new MySqlParameter();
            para[6].ParameterName = "inliquid_fk";
            if (inliquid_fk == string.Empty)
            {
                para[6].Value = null;
            }
            else
            {
                para[6].Value = int.Parse(inliquid_fk);
            }

            para[7] = new MySqlParameter();
            para[7].ParameterName = "inchr_fk";
            if (inchr_fk == string.Empty)
            {
                para[7].Value = null;
            }
            else
            {
                para[7].Value = int.Parse(inchr_fk);
            }

            para[8] = new MySqlParameter();
            para[8].ParameterName = "inncgas_fk";
            if (inncgas_fk == string.Empty)
            {
                para[8].Value = null;
            }
            else
            {
                para[8].Value = int.Parse(inncgas_fk);
            }

            para[9] = new MySqlParameter();
            para[9].ParameterName = "ingas_fk";
            if (ingas_fk == string.Empty)
            {
                para[9].Value = null;
            }
            else
            {
                para[9].Value = int.Parse(ingas_fk);
            }

            para[10] = new MySqlParameter();
            para[10].ParameterName = "inaqueous_fk";
            if (inaqueous_fk == string.Empty)
            {
                para[10].Value = null;
            }
            else
            {
                para[10].Value = int.Parse(inaqueous_fk);
            }

            para[11] = new MySqlParameter();
            para[11].ParameterName = "inoil_fk";
            if (inoil_fk == string.Empty)
            {
                para[11].Value = null;
            }
            else
            {
                para[11].Value = int.Parse(inoil_fk);
            }

            para[12] = new MySqlParameter();
            para[12].ParameterName = "inwater_fk";
            if (inwater_fk == string.Empty)
            {
                para[12].Value = null;
            }
            else
            {
                para[12].Value = int.Parse(inwater_fk);
            }

            para[13] = new MySqlParameter();
            para[13].ParameterName = "intBioUA_fk";
            if (stringBioUA_fk == string.Empty)
            {
                para[13].Value = null;
            }
            else
            {
                para[13].Value = int.Parse(stringBioUA_fk);
            }

            para[14] = new MySqlParameter();
            para[14].ParameterName = "intGasYield_fk";
            if (stringGasYield_fk == string.Empty)
            {
                para[14].Value = null;
            }
            else
            {
                para[14].Value = int.Parse(stringGasYield_fk);
            }

            para[15] = new MySqlParameter();
            para[15].ParameterName = "intPyr_Cal_fk";
            if (stringGasYield_fk == string.Empty)
            {
                para[15].Value = null;
            }
            else
            {
                para[15].Value = int.Parse(stringPyr_Cal_fk);
            }

            para[16] = new MySqlParameter();
            para[16].ParameterName = "Pry_Char_fk";
            if (Pry_Char_fk == string.Empty)
            {
                para[16].Value = null;
            }
            else
            {
                para[16].Value = int.Parse(Pry_Char_fk);
            }

            para[17] = new MySqlParameter();
            para[17].ParameterName = "intPyrOil_fk";
            if (stringPyrOil_fk == string.Empty)
            {
                para[17].Value = null;
            }
            else
            {
                para[17].Value = int.Parse(stringPyrOil_fk);
            }

            para[18] = new MySqlParameter();
            para[18].ParameterName = "intMaterialFk";
            if (stringMaterialFk == string.Empty)
            {
                para[18].Value = null;
            }
            else
            {
                para[18].Value = int.Parse(stringMaterialFk);
            }

            para[19] = new MySqlParameter();
            para[19].ParameterName = "vcexp_summary";
            if (vcexp_summary == string.Empty)
            {
                para[19].Value = null;
            }
            else
            {
                para[19].Value = vcexp_summary;
            }

            para[20] = new MySqlParameter();
            para[20].ParameterName = "vcsource";
            if (vcsource == string.Empty)
            {
                para[20].Value = null;
            }
            else
            {
                para[20].Value = vcsource;
            }

            para[21] = new MySqlParameter();
            para[21].ParameterName = "vchandlingHistory";
            if (vchandlingHistory == string.Empty)
            {
                para[21].Value = null;
            }
            else
            {
                para[21].Value = vchandlingHistory;
            }


            cmd1.Parameters.Add(para[0]);
            cmd1.Parameters.Add(para[1]);
            cmd1.Parameters.Add(para[2]);
            cmd1.Parameters.Add(para[3]);
            cmd1.Parameters.Add(para[4]);
            cmd1.Parameters.Add(para[5]);
            cmd1.Parameters.Add(para[6]);
            cmd1.Parameters.Add(para[7]);
            cmd1.Parameters.Add(para[8]);
            cmd1.Parameters.Add(para[9]);
            cmd1.Parameters.Add(para[10]);
            cmd1.Parameters.Add(para[11]);
            cmd1.Parameters.Add(para[12]);
            cmd1.Parameters.Add(para[13]);
            cmd1.Parameters.Add(para[14]);
            cmd1.Parameters.Add(para[15]);
            cmd1.Parameters.Add(para[16]);
            cmd1.Parameters.Add(para[17]);
            cmd1.Parameters.Add(para[18]);
            cmd1.Parameters.Add(para[19]);
            cmd1.Parameters.Add(para[20]);
            cmd1.Parameters.Add(para[21]);
            
            
            cmd1.ExecuteNonQuery();

            return "Experiment successfully updated";
           }

          catch (Exception ex)
          {
              return "Error occured in save operation.Contact system administrator" + ex.Message;
          }
          finally
          {
              conn.Close();
          }
            
        }

        public string SaveExperiment(string inproxanal_fk, string inultanal_fk, string incalanal_fk, string instruct_fk, string inphysprops_fk, string inconvcond_fk, string inliquid_fk, string inchr_fk, string inncgas_fk, string ingas_fk, string inaqueous_fk, string inoil_fk, string inwater_fk, string stringBioUA_fk, string stringGasYield_fk, string stringPyr_Cal_fk, string Pry_Char_fk, string stringPyrOil_fk, string stringMaterialFk, string vcexp_summary, string vcsource, string vchandlingHistory)
        {

            MySqlConnection conn = new MySqlConnection((string)ConfigurationSettings.AppSettings["LitReviewConnection"]);
            MySqlCommand cmd1;
            try
            {

                conn.Open();

                string storedProcedure = "Experiment_Save_Final";

                cmd1 = new MySqlCommand(storedProcedure, conn);

                cmd1.CommandType = CommandType.StoredProcedure;

                MySqlParameter[] para = new MySqlParameter[22];


                para[0] = new MySqlParameter();
                para[0].ParameterName = "inproxanal_fk";
                if (inproxanal_fk == string.Empty)
                {
                    inproxanal_fk = null;
                }
                else
                {
                    para[0].Value = int.Parse(inproxanal_fk);
                }

                para[1] = new MySqlParameter();
                para[1].ParameterName = "inultanal_fk";
                if (inultanal_fk == string.Empty)
                {
                    para[1].Value = null;
                }
                else
                {
                    para[1].Value = int.Parse(inultanal_fk);
                }

                para[2] = new MySqlParameter();
                para[2].ParameterName = "incalanal_fk";
                if (incalanal_fk == string.Empty)
                {
                    para[2].Value = null;
                }
                else
                {
                    para[2].Value = int.Parse(incalanal_fk);
                }

                para[3] = new MySqlParameter();
                para[3].ParameterName = "instruct_fk";
                if (instruct_fk == string.Empty)
                {
                    para[3].Value = null;
                }
                else
                {
                    para[3].Value = int.Parse(instruct_fk);
                }

                para[4] = new MySqlParameter();
                para[4].ParameterName = "inphysprops_fk";
                if (inphysprops_fk == string.Empty)
                {
                    para[4].Value = null;
                }
                else
                {
                    para[4].Value = int.Parse(inphysprops_fk);
                }

                para[5] = new MySqlParameter();
                para[5].ParameterName = "inconvcond_fk";
                if (inconvcond_fk == string.Empty)
                {
                    para[5].Value = null;
                }
                else
                {
                    para[5].Value = int.Parse(inconvcond_fk);
                }

                para[6] = new MySqlParameter();
                para[6].ParameterName = "inliquid_fk";
                if (inliquid_fk == string.Empty)
                {
                    para[6].Value = null;
                }
                else
                {
                    para[6].Value = int.Parse(inliquid_fk);
                }

                para[7] = new MySqlParameter();
                para[7].ParameterName = "inchr_fk";
                if (inchr_fk == string.Empty)
                {
                    para[7].Value = null;
                }
                else
                {
                    para[7].Value = int.Parse(inchr_fk);
                }

                para[8] = new MySqlParameter();
                para[8].ParameterName = "inncgas_fk";
                if (inncgas_fk == string.Empty)
                {
                    para[8].Value = null;
                }
                else
                {
                    para[8].Value = int.Parse(inncgas_fk);
                }

                para[9] = new MySqlParameter();
                para[9].ParameterName = "ingas_fk";
                if (ingas_fk == string.Empty)
                {
                    para[9].Value = null;
                }
                else
                {
                    para[9].Value = int.Parse(ingas_fk);
                }

                para[10] = new MySqlParameter();
                para[10].ParameterName = "inaqueous_fk";
                if (inaqueous_fk == string.Empty)
                {
                    para[10].Value = null;
                }
                else
                {
                    para[10].Value = int.Parse(inaqueous_fk);
                }

                para[11] = new MySqlParameter();
                para[11].ParameterName = "inoil_fk";
                if (inoil_fk == string.Empty)
                {
                    para[11].Value = null;
                }
                else
                {
                    para[11].Value = int.Parse(inoil_fk);
                }

                para[12] = new MySqlParameter();
                para[12].ParameterName = "inwater_fk";
                if (inwater_fk == string.Empty)
                {
                    para[12].Value = null;
                }
                else
                {
                    para[12].Value = int.Parse(inwater_fk);
                }

                para[13] = new MySqlParameter();
                para[13].ParameterName = "intBioUA_fk";
                if (stringBioUA_fk == string.Empty)
                {
                    para[13].Value = null;
                }
                else
                {
                    para[13].Value = int.Parse(stringBioUA_fk);
                }

                para[14] = new MySqlParameter();
                para[14].ParameterName = "intGasYield_fk";
                if (stringGasYield_fk == string.Empty)
                {
                    para[14].Value = null;
                }
                else
                {
                    para[14].Value = int.Parse(stringGasYield_fk);
                }

                para[15] = new MySqlParameter();
                para[15].ParameterName = "intPyr_Cal_fk";
                if (stringGasYield_fk == string.Empty)
                {
                    para[15].Value = null;
                }
                else
                {
                    para[15].Value = int.Parse(stringPyr_Cal_fk);
                }

                para[16] = new MySqlParameter();
                para[16].ParameterName = "Pry_Char_fk";
                if (Pry_Char_fk == string.Empty)
                {
                    para[16].Value = null;
                }
                else
                {
                    para[16].Value = int.Parse(Pry_Char_fk);
                }

                para[17] = new MySqlParameter();
                para[17].ParameterName = "intPyrOil_fk";
                if (stringPyrOil_fk == string.Empty)
                {
                    para[17].Value = null;
                }
                else
                {
                    para[17].Value = int.Parse(stringPyrOil_fk);
                }

                para[18] = new MySqlParameter();
                para[18].ParameterName = "intMaterialFk";
                if (stringMaterialFk == string.Empty)
                {
                    para[18].Value = null;
                }
                else
                {
                    para[18].Value = int.Parse(stringMaterialFk);
                }

                para[19] = new MySqlParameter();
                para[19].ParameterName = "vcexp_summary";
                if (vcexp_summary == string.Empty)
                {
                    para[19].Value = null;
                }
                else
                {
                    para[19].Value = int.Parse(vcexp_summary);
                }

                para[20] = new MySqlParameter();
                para[20].ParameterName = "vcsource";
                if (vcsource == string.Empty)
                {
                    para[20].Value = null;
                }
                else
                {
                    para[20].Value = int.Parse(vcsource);
                }

                para[21] = new MySqlParameter();
                para[21].ParameterName = "vchandlingHistory";
                if (vchandlingHistory == string.Empty)
                {
                    para[21].Value = null;
                }
                else
                {
                    para[21].Value = int.Parse(vchandlingHistory);
                }


                cmd1.Parameters.Add(para[0]);
                cmd1.Parameters.Add(para[1]);
                cmd1.Parameters.Add(para[2]);
                cmd1.Parameters.Add(para[3]);
                cmd1.Parameters.Add(para[4]);
                cmd1.Parameters.Add(para[5]);
                cmd1.Parameters.Add(para[6]);
                cmd1.Parameters.Add(para[7]);
                cmd1.Parameters.Add(para[8]);
                cmd1.Parameters.Add(para[9]);
                cmd1.Parameters.Add(para[10]);
                cmd1.Parameters.Add(para[11]);
                cmd1.Parameters.Add(para[12]);
                cmd1.Parameters.Add(para[13]);
                cmd1.Parameters.Add(para[14]);
                cmd1.Parameters.Add(para[15]);
                cmd1.Parameters.Add(para[16]);
                cmd1.Parameters.Add(para[17]);
                cmd1.Parameters.Add(para[18]);
                cmd1.Parameters.Add(para[19]);
                cmd1.Parameters.Add(para[20]);
                cmd1.Parameters.Add(para[21]);


                cmd1.ExecuteNonQuery();

                return "Experiment successfully updated";
            }

            catch (Exception ex)
            {
                return "Error occured in save operation.Contact system administrator" + ex.Message;
            }
            finally
            {
                conn.Close();
            }

        }

        public DataSet GetAshAnalysis(string Id)
        {
            
            MySqlConnection conn = new MySqlConnection((string)ConfigurationSettings.AppSettings["LitReviewConnection"]);
            try
            {
                MySqlCommand cmd1;
                MySqlDataAdapter ad1 = new MySqlDataAdapter();
                DataSet ds = new DataSet();
                cmd1 = new MySqlCommand("select misc_fk from gascomp where experiment_id="+ Id, conn);
                //cmd1.CommandType = CommandType.Text;
                ad1.SelectCommand = cmd1;
                conn.Open();
                ad1.Fill(ds);
                return ds;
            }
            finally
            {
                conn.Close();
            }

        }

        public DataSet GetCalorificAnalysis()
        {

            MySqlConnection conn = new MySqlConnection((string)ConfigurationSettings.AppSettings["LitReviewConnection"]);
            try
            {
                MySqlCommand cmd1;
                MySqlDataAdapter ad1 = new MySqlDataAdapter();
                DataSet ds = new DataSet();
                cmd1 = new MySqlCommand("Select * from calanal", conn);
                //cmd1.CommandType = CommandType.Text;
                ad1.SelectCommand = cmd1;
                conn.Open();
                ad1.Fill(ds);
                return ds;
            }
            finally
            {
                conn.Close();
            }


        }
               
        public DataSet GetProximityAnalysis()
        {
            MySqlConnection conn = new MySqlConnection((string)ConfigurationSettings.AppSettings["LitReviewConnection"]);
            try
            {
                MySqlCommand cmd1;
                MySqlDataAdapter ad1 = new MySqlDataAdapter();
                DataSet ds = new DataSet();
                cmd1 = new MySqlCommand("Select * from proxanal", conn);
                //cmd1.CommandType = CommandType.Text;
                ad1.SelectCommand = cmd1;
                conn.Open();
                ad1.Fill(ds);
                return ds;
            }
            finally
            {
                conn.Close();
            }
        }

        public DataSet GetGasCompoMisc(string Id)
        {
            MySqlConnection conn = new MySqlConnection((string)ConfigurationSettings.AppSettings["LitReviewConnection"]);
            try
            {
                MySqlCommand cmd1;
                MySqlDataAdapter ad1 = new MySqlDataAdapter();
                DataSet ds = new DataSet();
                cmd1 = new MySqlCommand("select * from gascomps_misc where id=(select misc_fk from gascomp where experiment_id=" + Id + ")", conn);
                ad1.SelectCommand = cmd1;
                conn.Open();
                ad1.Fill(ds);
                return ds;
            }
            finally
            {
                conn.Close();
            }
        }

        public DataSet GetOilCompoMisc(string ExperimentId)
        {
            MySqlConnection conn = new MySqlConnection((string)ConfigurationSettings.AppSettings["LitReviewConnection"]);
            try
            {
                MySqlCommand cmd1;
                MySqlDataAdapter ad1 = new MySqlDataAdapter();
                DataSet ds = new DataSet();
                cmd1 = new MySqlCommand("Select * from oilcomps_misc where experiment_id=" + ExperimentId, conn);
                ad1.SelectCommand = cmd1;
                conn.Open();
                ad1.Fill(ds);
                return ds;
            }
            finally
            {
                conn.Close();
            }
        }

        public string GetOilCompMiscPK(string ExperimentId)
        {
            MySqlConnection conn = new MySqlConnection((string)ConfigurationSettings.AppSettings["LitReviewConnection"]);
            try
            {
                MySqlCommand cmd1;
                conn.Open();
                cmd1 = new MySqlCommand("select id from oilcomps_misc where experiment_id=" + ExperimentId, conn);
                string OilComMiscPk = Convert.ToString(cmd1.ExecuteScalar());
                return OilComMiscPk;
            }
            finally
            {
                conn.Close();
            }
        }

        public DataSet GetMaterialName()
        {
            MySqlConnection conn = new MySqlConnection((string)ConfigurationSettings.AppSettings["LitReviewConnection"]);
            try
            {
                MySqlCommand cmd1;
                MySqlDataAdapter ad1 = new MySqlDataAdapter();
                DataSet ds = new DataSet();
                cmd1 = new MySqlCommand("select distinct name from material", conn);
                ad1.SelectCommand = cmd1;
                conn.Open();
                ad1.Fill(ds);
                return ds;
            }
            finally
            {
                conn.Close();
            }
        }

        public DataSet GetConversionConTemDetails()
        {
            MySqlConnection conn = new MySqlConnection((string)ConfigurationSettings.AppSettings["LitReviewConnection"]);
            try
            {
                MySqlCommand cmd1;
                MySqlDataAdapter ad1 = new MySqlDataAdapter();
                DataSet ds = new DataSet();
                cmd1 = new MySqlCommand("select distinct temp from convconditions;", conn);
                ad1.SelectCommand = cmd1;
                conn.Open();
                ad1.Fill(ds);
                return ds;
            }
            finally
            {
                conn.Close();
            }
        }

        public DataSet GetConversionConRegimeDetails()
        {
            MySqlConnection conn = new MySqlConnection((string)ConfigurationSettings.AppSettings["LitReviewConnection"]);
            try
            {
                MySqlCommand cmd1;
                MySqlDataAdapter ad1 = new MySqlDataAdapter();
                DataSet ds = new DataSet();
                cmd1 = new MySqlCommand("select distinct conv_Regime from convconditions;", conn);
                ad1.SelectCommand = cmd1;
                conn.Open();
                ad1.Fill(ds);
                return ds;
            }
            finally
            {
                conn.Close();
            }
        }

        public DataSet GetConversionConGasificationMethodDetails()
        {
            MySqlConnection conn = new MySqlConnection((string)ConfigurationSettings.AppSettings["LitReviewConnection"]);
            try
            {
                MySqlCommand cmd1;
                MySqlDataAdapter ad1 = new MySqlDataAdapter();
                DataSet ds = new DataSet();
                cmd1 = new MySqlCommand("select distinct gasificationMed from convconditions;", conn);
                ad1.SelectCommand = cmd1;
                conn.Open();
                ad1.Fill(ds);
                return ds;
            }
            finally
            {
                conn.Close();
            }
        }

        public DataSet GetExperimentIdBasedonConversionCondition(string Regime, string Temp, string GasificationMethod)
        {
            MySqlConnection conn = new MySqlConnection((string)ConfigurationSettings.AppSettings["LitReviewConnection"]);
            try
            {
                MySqlCommand cmd1;
                MySqlDataAdapter ad1 = new MySqlDataAdapter();
                DataSet ds = new DataSet();
                cmd1 = new MySqlCommand("select * from Experiment where convcond_fk in (Select id from convconditions where conv_Regime='" + Regime + "'" + "  and temp='" + Temp + "'" + "  and gasificationMed='" + GasificationMethod + "')", conn);
                ad1.SelectCommand = cmd1;
                conn.Open();
                ad1.Fill(ds);
                return ds;
            }
            finally
            {
                conn.Close();
            }
        }

        public static void ExportToExcel(DataTable dt,HttpResponse response,String FileName)
        {
            response.Clear();
            response.AddHeader("content-disposition", "attachment;filename=" + FileName + ".xls");
            response.Charset = "";
            response.ContentType = "application/vnd.ms-excel";
            System.IO.StringWriter stringWrite = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter htmlWrite =new HtmlTextWriter(stringWrite);
            DataGrid dg = new DataGrid();
            dg.DataSource = dt;
            dg.DataBind();
            dg.RenderControl(htmlWrite);
            response.Write(stringWrite.ToString());
            response.End();
        }


        public string GetExpYieldId(string ExperimentId)
        {
            string query = "select id from yields where experiment_id=" + ExperimentId;
            MySqlConnection con1 = new MySqlConnection((string)ConfigurationSettings.AppSettings["LitReviewConnection"]);
            con1.Open();
            MySqlCommand cmd = new MySqlCommand(query, con1);
            string YieldId = Convert.ToString(cmd.ExecuteScalar());
            con1.Close();
            return YieldId;

        }

        public string ExpGetLiquidComId(string ExperimentId)
        {
            string query = "select id from liquidcomp where experiment_id=" + ExperimentId;
            MySqlConnection con1 = new MySqlConnection((string)ConfigurationSettings.AppSettings["LitReviewConnection"]);
            con1.Open();
            MySqlCommand cmd = new MySqlCommand(query, con1);
            string LiquidCompId = Convert.ToString(cmd.ExecuteScalar());
            con1.Close();
            return LiquidCompId;


        }



    }
}